import axios from 'axios'
import Message from 'element-ui'

/**
 * 获取组织架构列表
 */
export const getDepartmentList = () => {
  try {
    const response = axios.get('http://localhost:3000/department')
    return response
  } catch (error) {
    Message({ type: 'error', message: '获取组织架构列表失败' })
    return Promise.reject(error)
  }
}

/**
 * 新增部门
 */
export const addDepartment = (data) => {
  try {
    const response = axios.post('http://localhost:3000/department', data)
    return response
  } catch (error) {
    Message({ type: 'error', message: '新增部门失败' })
    return Promise.reject(error)
  }
}
/**
 * 删除部门
 */
export const delDepartment = (id) => {
  try {
    const response = axios.delete(`http://localhost:3000/department/${id}`)
    return response
  } catch (error) {
    Message({ type: 'error', message: '删除部门失败' })
    return Promise.reject(error)
  }
}
